{
  "$schema" : "http://json-schema.org/draft/2019-09/schema#",
  "title" : "Credit Reference",
  "type" : "object",
  "additionalProperties" : false,
  "properties" : {
    "interfaceCategory" : {
      "type" : "string",
      "maxLength" : 20,
      "enum" : [ "Credit Management" ],
      "description" : "CMP categorisation of the job associated with this file"
    },
    "interfaceType" : {
      "type" : "string",
      "maxLength" : 24,
      "enum" : [ "Credit Reference" ],
      "description" : "Sub-categorisation of the job"
    },
    "version" : {
      "type" : "number",
      "minimum" : 0.0,
      "maximum" : 99.99,
      "description" : "The current version of the generic extract file. This must match the corresponding inbound file."
    },
    "recordCount" : {
      "type" : "integer",
      "minimum" : 0,
      "description" : ""
    },
    "isoCurrencyCode" : {
      "type" : "string",
      "pattern" : "^([a-zA-Z]){3}",
      "minLength" : 3,
      "maxLength" : 3,
      "description" : ""
    },
    "accounts" : {
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/Account"
      }
    },
    "id" : {
      "type" : "integer",
      "description" : "Unique identifier for each generic extract file that is produced by CMP."
    },
    "batchDateTime" : {
      "type" : "string",
      "format" : "date-time",
      "description" : ""
    },
    "extractDateTime" : {
      "type" : "string",
      "format" : "date-time",
      "description" : ""
    }
  },
  "required" : [ "version", "recordCount", "isoCurrencyCode", "id" ],
  "definitions" : {
    "Account" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "accountId" : {
          "type" : "integer",
          "minimum" : 1,
          "maximum" : 99999999,
          "description" : "The unique identifier for the account in CMP."
        },
        "accountCreationDate" : {
          "type" : "string",
          "format" : "date-time",
          "description" : "This is the value of the Account Creation Date on the Account Extension/Account view."
        },
        "endDate" : {
          "type" : "string",
          "format" : "date-time",
          "description" : ""
        },
        "dateOfBirth" : {
          "type" : "string",
          "format" : "date-time",
          "description" : ""
        },
        "currentStatus" : {
          "type" : "string",
          "enum" : [ "SETTLED", "IN_QUERY", "PAY_ARRANGE", "UP_TO_DATE", "ARREARS", "DEFAULTED", "NEW_DEFAULTED" ],
          "description" : ""
        },
        "accountTypeClassification" : {
          "type" : "string",
          "enum" : [ "CLOSED", "DEBT_MANAGEMENT", "DECEASED_SUBSCRIBER", "DEFAULTED", "FRAUD", "GONE_AWAY", "PARTIAL_SETTLEMENT", "PAYMENT_ARRANGEMENT", "STD_ACCOUNT_TYPE", "WRITTEN_OFF", "SUSPECTED_FRAUD", "IN_QUERY", "DEBT_ASSIGNED", "DEBT_SOLD" ],
          "description" : ""
        },
        "deleteAccount" : {
          "type" : "string",
          "enum" : [ "MANUAL", "FRAUD", "NO" ],
          "description" : ""
        },
        "isCurrentBalanceChanged" : {
          "type" : "boolean",
          "description" : "This can be retreived from the CreditReferenceExtractBatchDetail by the Extract Daemon."
        },
        "currentBalanceDue" : {
          "type" : "number",
          "minimum" : 0.0,
          "maximum" : 9.9999999999E8,
          "description" : ""
        },
        "currentBalance" : {
          "type" : "number",
          "minimum" : 0.0,
          "maximum" : 9.9999999999E8,
          "description" : ""
        },
        "balanceWrittenOff" : {
          "type" : "number",
          "minimum" : 0.0,
          "maximum" : 9.9999999999E8,
          "description" : ""
        },
        "pendingCreditAdjustments" : {
          "type" : "number",
          "minimum" : 0.0,
          "maximum" : 9.9999999999E8,
          "description" : ""
        },
        "defaulted" : {
          "$ref" : "#/definitions/Defaulted",
          "description" : ""
        },
        "amountInQuery" : {
          "type" : "number",
          "minimum" : 0.0,
          "maximum" : 9.9999999999E8,
          "description" : ""
        },
        "amountInQueryDue" : {
          "type" : "number",
          "minimum" : 0.0,
          "maximum" : 9.9999999999E8,
          "description" : ""
        },
        "arrears" : {
          "$ref" : "#/definitions/Arrears",
          "description" : ""
        },
        "paymentFrequencyUnits" : {
          "type" : "string",
          "enum" : [ "M", "D" ],
          "description" : ""
        },
        "paymentFrequency" : {
          "type" : "integer",
          "minimum" : 1,
          "maximum" : 999,
          "description" : ""
        },
        "paymentArrangement" : {
          "$ref" : "#/definitions/PaymentArrangement",
          "description" : ""
        },
        "isPostalAddressChanged" : {
          "type" : "boolean",
          "description" : ""
        },
        "postalAddress" : {
          "$ref" : "#/definitions/PostalAddress",
          "description" : ""
        }
      },
      "required" : [ "accountId", "accountCreationDate", "currentStatus", "deleteAccount", "isCurrentBalanceChanged", "currentBalanceDue", "currentBalance", "pendingCreditAdjustments", "amountInQuery", "amountInQueryDue", "paymentFrequencyUnits", "paymentFrequency", "isPostalAddressChanged" ]
    },
    "Defaulted" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "date" : {
          "type" : "string",
          "format" : "date-time",
          "description" : ""
        },
        "balance" : {
          "type" : "number",
          "minimum" : 0.0,
          "maximum" : 9.9999999999E8,
          "description" : ""
        }
      }
    },
    "Arrears" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "amount" : {
          "type" : "number",
          "minimum" : 0.0,
          "maximum" : 9.9999999999E8,
          "description" : ""
        },
        "ageOfOldestOutstandingAmountDays" : {
          "type" : "integer",
          "minimum" : 0,
          "maximum" : 9999,
          "description" : ""
        }
      },
      "required" : [ "amount", "ageOfOldestOutstandingAmountDays" ]
    },
    "PaymentArrangement" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "regularAmount" : {
          "type" : "number",
          "minimum" : 0.0,
          "maximum" : 9.9999999999E8,
          "description" : ""
        },
        "repaymentFrequencyUnits" : {
          "type" : "string",
          "enum" : [ "W", "M" ],
          "description" : ""
        },
        "paymentFrequency" : {
          "type" : "integer",
          "minimum" : 0,
          "maximum" : 999,
          "description" : ""
        },
        "repaymentPeriod" : {
          "type" : "integer",
          "minimum" : 1,
          "maximum" : 999,
          "description" : ""
        },
        "planEndDate" : {
          "type" : "string",
          "format" : "date-time",
          "description" : ""
        }
      }
    },
    "PostalAddress" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "title" : {
          "type" : "string",
          "maxLength" : 10,
          "description" : "The title of the customer e.g. Mr, Mrs etc"
        },
        "foreName" : {
          "type" : "string",
          "maxLength" : 15,
          "description" : "The customers first name"
        },
        "middleName" : {
          "type" : "string",
          "maxLength" : 10,
          "description" : "The customers middle name"
        },
        "surname" : {
          "type" : "string",
          "maxLength" : 25,
          "description" : "The customers surname."
        },
        "companyName" : {
          "type" : "string",
          "maxLength" : 60,
          "description" : "The name of hte company. Only applicable when the address is stored as a company address in CMP."
        },
        "postCode" : {
          "type" : "string",
          "maxLength" : 10,
          "description" : "The customer's post code."
        },
        "addressLines" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/AddressLine"
          },
          "description" : "Lines of the address."
        }
      }
    },
    "AddressLine" : {
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "line" : {
          "type" : "string",
          "maxLength" : 40,
          "description" : ""
        }
      }
    }
  }
}